class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None


class Solution:
    def getKthFromEnd(self, head: ListNode, k: int) -> ListNode:
        stack = []
        while( head!=None):
            stack.append(head)
            head = head.next
        return stack[-1*k]
